#include "widget.h"
#include "ui_widget.h"
int flag=0;

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    ti=new QTimer(this);
    connect(ti,SIGNAL(timeout()),this,SLOT(Change()));
    ti->start(1000);


}

Widget::~Widget()
{
    delete ui;
}
void Widget::Change()
{
    if(flag==0)
    {
        ui->lineEdit->setText("你好");
        flag=1;
    }
    else
    {
        ui->lineEdit->setText("猪猪");
        flag=0;
    }
}

void Widget::on_pushButton_clicked()
{
    //从0时0分0秒开始，到当前时间
    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
    int num=qrand()%10;
    //lineEdit里面显示字符串，用QString把int num转换成字符串
    QString tmp=QString::number(num,10);
    ui->lineEdit_2->setText(tmp);


}
